import { get, post, put, del } from '@/utils'

export const useGetUsers = (params: any) => {
  const { page, size } = params
  delete params.page
  delete params.size
  if (Object.keys(params).length === 0) {
    return post(`/user/page/${page}/${size}`, { search: null })
  }
  return post(`/user/page/${page}/${size}`, { search: params })
}

export const useGetUserRoles = (params: any) => {
  return get('/user/info/roles', params)
}

export const useEditUserRoles = (username: string, params: any) => {
  return put(`user/edit/roles/${username}`, params)
}

export const useDeleteUser = (userId: number) => {
  return del(`user/del/${userId}`)
}

export const useDeleteusers = (userids: number[]) => {
  return del('user/del/batch', userids)
}

export const useAddUser = (user: any) => {
  return post('/user/plus', user)
}
